-- 图形验证码校验脚本
-- 获取验证码
local key = 'captcha:picture:'..KEYS[1]
local rightCode = redis.call('get', key)
if not rightCode then -- https://cloud.tencent.com/developer/ask/sof/113950503
    return 1
end

-- 判断验证码是否正确
local userCode = ARGV[1]
if not(string.lower(rightCode) == string.lower(userCode)) then
    -- 错误就删除验证码
    redis.call('del', key)
    return 2
end


-- 删除验证码
redis.call('del', key)
return 0


